﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Net.Chirash.Twitter.TwitterDatabase;

namespace Net.Chirash.Twitter.TwitterClient
{
    public class DeletedData
        : TwitterData 
    {
        public long ID { get; set; }
        public long UserID { get; set; }
        public Type DeletedType { get; set; }

        public static DeletedData Parse(string xml)
        {
            var data = new DeletedData();
            var element = new XElement(xml);

            data.ID = long.Parse(element.Element("id").Value);
            data.UserID = long.Parse(element.Element("user_id").Value);

            if (element.Element("status") != null)
            {
                data.DeletedType = typeof(Status);
            }
            else if (element.Element("direct_message") != null)
            {
                data.DeletedType = typeof(DirectMessage);
            }

            return data;
        }
    }
}
